//
//  BaseNetworkRequest.m
//  ShiWuPai
//
//  Created by app on 16/11/24.
//  Copyright © 2016年 QQ:244987427. All rights reserved.
//

#import "BaseNetworkRequest.h"
#import <AFNetworking.h>
#define BaseURLString(string) [NSString stringWithFormat:@"http://food.boohee.com/fb/v1/%@",string]
@interface BaseNetworkRequest ()

@end
@implementation BaseNetworkRequest

+(void)rquestWithType:(NSString *)type Path:(NSString *)path Parameters:(NSDictionary *)parameters success:(void(^)(id responseObj,NSError *error))completionHandler{
    path=BaseURLString(path);
    AFHTTPSessionManager *manager=[AFHTTPSessionManager manager];
    if ([type isEqualToString:@"GET"]) {
        [manager GET:path parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
            completionHandler(responseObject,nil);
        } failure:^(NSURLSessionDataTask *task, NSError *error) {
            completionHandler(nil,error);
        }];

    }
    
    if ([type isEqualToString:@"POST"]) {
        [manager POST:path parameters:path success:^(NSURLSessionDataTask *task, id responseObject) {
            completionHandler(responseObject,nil);
        } failure:^(NSURLSessionDataTask *task, NSError *error) {
             completionHandler(nil,error);
        }];
        
    }

    
}
@end
